package com.helloandroid.paso.ui.diszko;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.helloandroid.paso.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {

    int diszkoGalleryItemBackground;
    private Context mContext;

    //TODO Tamas: images should be in default resource directory, drawable-mdpi, not hdpi
    private Integer[] diszkoImageIds = {
    		//albums image
    		R.drawable.discografia_imtheone,
            R.drawable.discografia_ftr,
            R.drawable.discografia_return1,
            R.drawable.discografia_rebsm,
            R.drawable.discografia_bibl_7,
            R.drawable.discografia_babylonfocus,
            R.drawable.discografia_bsm,
            R.drawable.discografia_all_night_long,
            R.drawable.discografia_demo,
            //dvd image
            R.drawable.discografia_dvd,
            //other image
            R.drawable.discografia_skan8_tn,
            R.drawable.discografia_ucos4,
            R.drawable.discografia_weare,
            R.drawable.discografia_klubost,
            R.drawable.discografia_biturbo,
            R.drawable.discografia_mega,
            R.drawable.discografia_mill1,
            R.drawable.discografia_illes,
            R.drawable.discografia_skaland_2005,
            R.drawable.discografia_tilos,
            R.drawable.discografia_tilos06,
            R.drawable.discografia_tilos2007,
            R.drawable.discografia_cst,
            R.drawable.discografia_wmfh,
            R.drawable.discografia_mr23,
            R.drawable.discografia_mr21,
            R.drawable.discografia_lgt,
            R.drawable.discografia_sdt,
            R.drawable.discografia_move,
            
    };
    
    public ImageAdapter(Context c) {
        mContext = c;
        TypedArray a = c.obtainStyledAttributes(R.styleable.diszko_ui_gallery);
        diszkoGalleryItemBackground = a.getResourceId(
                R.styleable.diszko_ui_gallery_android_galleryItemBackground, 0);
        a.recycle();
    }
	
	@Override
	public int getCount() {
		 return diszkoImageIds.length;
	}

	@Override
	public Object getItem(int position) {
        return position;
    }

	@Override
	public long getItemId(int position) {
            return position;
    }

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
        ImageView i = new ImageView(mContext);

        i.setImageResource(diszkoImageIds[position]);
        i.setLayoutParams(new Gallery.LayoutParams(100, 100));
        i.setScaleType(ImageView.ScaleType.CENTER);
        i.setBackgroundResource(diszkoGalleryItemBackground);

        return i;
    }

}
